package org.example.rabbitmq.controller;

import org.example.rabbitmq.server.publish.EventPublisher;
import org.example.rabbitmq.vo.TenantId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class EventController {
    @Autowired
    EventPublisher eventPublisher;

    @RequestMapping("/{tenant}/{msg}")
    public String publish(@PathVariable("tenant") Long tenantId, @PathVariable("msg") String msg) {
        eventPublisher.publish(new TenantId(tenantId), msg);
        return "published";
    }
}
